package clientGUI.userPanels;

import clientGUI.Controllers.Controller;
import clientGUI.userPanels.Controllers.SupervisorController;
import clientserver.Client;
import college.User;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JComboBox;

public class SupervisorEvalApprovePanel extends UPanel {
	SupervisorController controller;
	User currentUser;
	private JTextField selVal;
	private JComboBox evCB;
	private JLabel ridlbl;
	public SupervisorEvalApprovePanel(int rid, Client cl, User u) {
		super();
		setLayout(null);
		controller = new SupervisorController(cl,rid);
		currentUser = u;
		
		JLabel lblSelectedEvaluator = new JLabel("Current Evaluator:");
		lblSelectedEvaluator.setBounds(50, 67, 205, 20);
		add(lblSelectedEvaluator);
		
		JButton approve = new JButton("Approve");
		approve.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				controller.approvedEvaluator();
			}
		});
		
		approve.setBounds(334, 66, 91, 23);
		add(approve);
		
		JButton disapprove = new JButton("Set new Evaluator");
		disapprove.addActionListener(new ActionListener() {
			
			
			public void actionPerformed(ActionEvent e) {
				String str =(String) evCB.getSelectedItem();
				controller.SetNewEvaluator(str);
				selVal.setText(str);
			}
		});
		disapprove.setBounds(334, 100, 91, 23);
		add(disapprove);
		
		
		selVal = new JTextField(controller.getcurrEval());
		selVal.setEditable(false);
		selVal.setBounds(241, 67, 86, 20);
		add(selVal);
		selVal.setColumns(10);
		
		JLabel lblChooseAnotherOne = new JLabel("Candidates to Evaluator position:");
		lblChooseAnotherOne.setBounds(60, 104, 181, 14);
		add(lblChooseAnotherOne);
		
		evCB = new JComboBox(controller.getAllPosibleEvaluators().toArray());
		evCB.setBounds(251, 101, 73, 20);
		add(evCB);
		
		ridlbl = new JLabel("Choosing evaluator for Vhange equest N"+rid);
		ridlbl.setBounds(137, 11, 142, 14);
		add(ridlbl);
		
		JButton btnBack = new JButton("Main Menu");
		btnBack.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				myframe.SetMainUserPanel();
			}
		});
		btnBack.setBounds(190, 213, 89, 23);
		add(btnBack);
	}
}
